package com.awenhui.demo.demo.thread;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author yuxf
 * @version 1.0
 * @date 2021/7/1 9:08
 */
public class UnsaftList {
    static List<String> list = Collections.synchronizedList( new ArrayList<>());

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 10000; i++) {

            int finalI = i;
            new Thread(() -> {
                list.add(finalI +"");

            }).start();
        }
        Thread.sleep(1500);
        System.out.println("添加完成："+list.size());
    }
}


